{template 'common/header-storex'}

<div class="wn-main">
	<div class="wn-main__head">应用</div>
	<div class="wn-main__content">
		<div class="wn-tabs">
			<div class="wn-tabs__item {if $op == 'roommanage'}wn-tabs__item--active{/if}">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'roommanage', 'storeid' => $_GPC['storeid']))}">客房管理</a>
			</div>
			<div class="wn-tabs__item {if $op == 'telmanage'}wn-tabs__item--active{/if}">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'telmanage', 'storeid' => $_GPC['storeid']))}">电话设置</a>
			</div>
			<div class="wn-tabs__item {if $op == 'room_goods'}wn-tabs__item--active{/if}">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'room_goods', 'storeid' => $_GPC['storeid']))}">房间商品</a>
			</div>
			<div class="wn-tabs__item {if in_array($op, array('foods_set', 'foods_lists', 'foods_edit', 'foods_delete', 'foods_deleteall', 'foods_showall', 'foods_status', 'foods_order', 'foods_deleteorder', 'foods_deleteorderall', 'foods_editorder'))}wn-tabs__item--active{/if}">
				<a class="wn-tabs__link" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_set', 'storeid' => $_GPC['storeid']))}">订餐服务</a>
			</div>
		</div>
		{if $op == 'roommanage'}
		<div class="clearfix">
			<table class="table table-hover we7-table">
				<col />
				<col />
				<thead class="navbar-inner">
					<tr>
						<th>预约信息</th>
						<th>预约时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $room_items $id $item}
					<tr>
						<td>
							{$item['info']}
						</td>
						<td>{php echo date('Y-m-d H:i:s', $item['time'])}</td>
						<td class="text-left">
							{if $item['status'] == 1}
							<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'confirm', 'storeid' => $_GPC['storeid'], 'id' => $id))}" class="color-default">待确认</a>
							{elseif $item['status'] == 2}
							<a href="javascript:;">已确认</a>
							{/if}
						</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
		{/if}
		{if $op == 'telmanage'}
		<div class="clearfix">
			<form class="form-horizontal form" method="post" enctype="multipart/form-data">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">前台电话</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id="tel" name="tel" class="form-control" value="{$tel_info['tel']}">
					</div>
				</div>
				<div class="form-group col-sm-12">
					<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</form>
		</div>
		{/if}
		{if $op == 'room_goods'}
		<div class="modal fade" id="goods-modal" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">添加商品</h4>
					</div>
					<div class="modal-body clearfix form-horizontal">
						<div class="form-group">
							<div class="col-sm-12 col-xs-12">
								<div class="input-group">
									<span class="input-group-addon">商品名称</span>
									<input type="text" name="title" value="" class="form-control">
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12 col-xs-12">
								<div class="input-group">
									<span class="input-group-addon">商品价格</span>
									<input type="text" name="price" value="" class="form-control">
									<span class="input-group-addon">元</span>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<input type="hidden" name="goods_id">
						<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
						<button type="button" class="btn btn-primary js-submit-goods">确定</button>
					</div>
				</div>
			</div>
		</div>
		<div class="wn-main__search__action">
			<a href="javascript:;" id="add_goods" class="btn btn-primary we7-padding-horizontal">+添加商品</a>
		</div>
		<div class="clearfix">
			<table class="table table-hover we7-table">
				<thead class="navbar-inner">
					<tr>
						<th>名称</th>
						<th>价格(元)</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $goods_list $goods}
					<tr>
						<td>
							{$goods['title']}
						</td>
						<td>{$goods['price']}</td>
						<td class="text-left">
							{if $goods['status'] == 1}
							<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'goods_status', 'storeid' => $_GPC['storeid'], 'id' => $goods['id'], 'status' => 2))}" class="color-default">上架中</a>
							{elseif $goods['status'] == 2}
							<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'goods_status', 'storeid' => $_GPC['storeid'], 'id' => $goods['id'], 'status' => 1))}">已下架</a>
							{/if}
							<a href="javascript:;" class="color-default js-edit-goods" data-id="{$goods['id']}">编辑</a>
							<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'goods_delete', 'storeid' => $_GPC['storeid'], 'id' => $goods['id']))}" class="color-default">删除</a>
						</td>
					</tr>
					{/loop}
				</tbody>
			</table>
		</div>
		<script type="text/javascript">
		$('#add_goods').click(function() {
			$('#goods-modal').modal('show');
		});
		$('.js-submit-goods').click(function() {
			title = $('input[name="title"]').val();
			price = $('input[name="price"]').val();
			id = $('input[name="goods_id"]').val();
			if (!title || !price || price < 0) {
				util.message('不能为空或负数', '', 'error');
				return;
			}
			$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice', array('storeid' => $_GPC['storeid'], 'op' => 'room_goods'))}", {title : title, price : price, id : id}, function(data) {
				data = $.parseJSON(data);
				if (data.message.errno !=0) {
					util.message(data.message.message, '', 'error');
				} else {
					util.message('编辑成功', data.redirect, 'success');
					$('#goods-modal').modal('hide');
				}
			});
		});
		$('.js-edit-goods').click(function() {
			id = $(this).data('id');
			$('input[name="goods_id"]').val(id);
			$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice', array('storeid' => $_GPC['storeid'], 'op' => 'goods_info'))}", {id : id}, function(data) {
				data = $.parseJSON(data);
				$('input[name="title"]').val(data.message.message.title);
				$('input[name="price"]').val(data.message.message.price);
				$('#goods-modal').modal('show');
			});
		});
		</script>
		{/if}
		{if $op == 'foods_set'}
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_order', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">餐品订单</a>
		</div>
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_edit', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">+添加餐品</a>
		</div>
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_lists', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">餐品列表</a>
		</div>
		<div class="wn-main__content">
			<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
				<input type="hidden" name="storeid" value="{$storeid}">
				<input type="hidden" name="do" value="shop_plugin_hotelservice">
				<input type="hidden" name="op" value="foods_set">
				<input type="hidden" name="m" value="wn_storex">
				<input type="hidden" name="id" value="{$foods_set['id']}">
				<div class="form-group">
					<label class="col-xs-12 col-md-2 control-label">就餐地点设置</label>
					<div class="col-md-10" id="food_place" style="padding-left: 0px;">
						{loop $food_place $key $place}
						<div class="col-sm-11" style="margin: 5px 0px;">
							<div class="input-group">
								<input type="text" class="form-control place-input" maxlength="6" name="place[{$key}]" value="{$place}">
								<span class="input-group-btn">
									<button class="btn btn-default place-delete" type="button">删除</button>
								</span>
							</div>
						</div>
						{/loop}
						<div class="col-sm-5">
							<button type="button" id="add_food_place" class="btn btn-default"><i class="fa fa-plus"></i> 添加就餐地点</button>
							<span class='help-block'>例如：房间，餐厅等，根据店铺配置填写。</span>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-md-2 control-label">餐点设置</label>
					<div class="col-md-10" id="food_time" style="padding-left: 0px;">
						{loop $food_times $key $time}
						<div class="col-sm-11" style="margin: 5px 0px;">
							<div class="input-group">
								<input type="text" class="form-control time-input" maxlength="6" name="time[{$key}]" value="{$time}">
								<span class="input-group-btn">
									<button class="btn btn-default time-delete" type="button">删除</button>
								</span>
							</div>
						</div>
						{/loop}
						<div class="col-sm-5">
							<button type="button" id="add_food_time" class="btn btn-default"><i class="fa fa-plus"></i> 添加餐点设置</button>
							<span class='help-block'>例如：早餐，午餐，晚餐，根据店铺配置填写。</span>
						</div>
					</div>
				</div>
				<div class="form-group col-sm-12">
					<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</form>
		</div>
		{/if}
		{if $op == 'foods_lists'}
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_order', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">餐品订单</a>
		</div>
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_edit', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">+添加餐品</a>
		</div>
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_set', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">酒店订餐设置</a>
		</div>
		<table class="table table-hover wn-table table-bordered" >
			<thead class="navbar-inner">
				<tr>
					<th class='with-checkbox' style='width:30px;'>
						<input type="checkbox" class="check_all_foods" />
					</th>
					<th style="width:100px;">餐品名称</th>
					<th style="width:100px;">餐品价格</th>
					<th style="width:150px;">餐品已售数量</th>
					<th style="width:100px;">状态</th>
					<th style="width:420px;">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $foods $item}
			<tr>
				<td class="with-checkbox">
					<input type="checkbox" name="check_foods" value="{$item['id']}">
				</td>
				<td>{$item['title']}</td>
				<td>{$item['price']}</td>
				<td>{$item['sold_num']}</td>
				<td>{if $item['status'] == 2}
					<a title="隐藏" href="javascript:;" onclick="drop_confirm('您确定要显示此餐品吗?', '{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_status', 'status' => 1, 'id' => $item['id'], 'storeid' => $storeid))}');"><span class='label label-default'>隐藏</span></a>
					{elseif $item['status'] == 1}
					<a title="显示" href="javascript:;" onclick="drop_confirm('您确定要隐藏此餐品吗?', '{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_status', 'status' => 2, 'id' => $item['id'], 'storeid' => $storeid))}');"><span class='label label-success'>显示</span></a>
					{/if}
				</td>
				<td>
					<div>
						<a class="wn-table__link__item" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_edit', 'id' => $item['id'], 'storeid' => $storeid))}" title="编辑">编辑</a>
						<a class="wn-table__link__item" href="javascript:;" onclick="drop_confirm('您确定要删除吗?', '{php echo $this->createWebUrl('shop_plugin_hotelservice',array('op' => 'foods_delete', 'id' => $item['id'], 'storeid' => $storeid))}');" title="删除" >删除</a>
					</div>
				</td>
			</tr>
			{/loop}
			<tr>
				<td colspan="11">
					<input type="button" class="btn btn-primary" name="foods_deleteall" value="删除选择的" />
					<input type="button" class="btn btn-primary foods_edit_all" name="foods_showall" value="批量显示" />
					<input type="button" class="btn btn-primary foods_edit_all" name="foods_hideall" value="批量隐藏" />
					<div class="pull-right">
						{$pager}
					</div>
				</td>
			</tr>
			</tbody>
			<input name="token" type="hidden" value="{$_W['token']}" />
		</table>
		{/if}
		{if $op == 'foods_edit'}
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_lists', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">+返回餐品列表</a>
		</div>
		<div class="wn-main__content">
			<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
				<input type="hidden" name="storeid" value="{$storeid}">
				<input type="hidden" name="do" value="shop_plugin_hotelservice">
				<input type="hidden" name="op" value="foods_edit">
				<input type="hidden" name="m" value="wn_storex">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">餐品名称</label>
					<div class="col-sm-10">
						<input class="form-control" name="title" type="text" placeholder="" value="{$food['title']}">
						<span class="help-block">餐品的名称（15个字符）</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">所属餐点</label>
					<div class="col-sm-10">
						{loop $food_times $title}
						<label class='checkbox-inline' style='margin-top:-5px;'>
						<input type='checkbox' name="foods_set[]" value="{$title}" {if !empty($food['foods_set']) && in_array($title, $food['foods_set'])} checked {/if}/>{$title}
						</label>
						{/loop}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">餐品价格</label>
					<div class="col-sm-10">
						<input class="form-control" name="price" type="text" placeholder="" value="{$food['price']}">
						<span class="help-block">餐品的价格</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">已售数量</label>
					<div class="col-sm-10">
						<input class="form-control" name="sold_num" type="number" value="{$food['sold_num']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">餐品图片</label>
					<div class="col-sm-10">
						{php echo tpl_form_field_multi_image('thumbs',$food['thumbs'])}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">餐品描述</label>
					<div class="col-sm-10">
						{php echo tpl_ueditor('content', $food['content']);}
						<span class="help-block">餐品内容</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">餐品状态</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline">
							<input type="radio" name="status" value="1" {if empty($item['status']) || $item['status'] == 1} checked {/if}/>显示
						</label>
						<label class="radio-inline">
							<input type="radio" name="status" value="2" {if $item['status'] == 2} checked {/if}/>隐藏
						</label>
						<span class='help-block'>手机前台是否显示</span>
					</div>
				</div>
				<div class="form-group col-sm-12">
					<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</form>
		</div>
		{/if}
		{if $op == 'foods_order'}
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_lists', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">餐品列表</a>
		</div>
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_edit', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">+添加餐品</a>
		</div>
		<table class="table table-hover wn-table table-bordered" >
			<thead class="navbar-inner">
				<tr>
					<th class='with-checkbox' style='width:30px;'>
						<input type="checkbox" class="check_all_order" />
					</th>
					<th style="width:100px;">联系人</th>
					<th style="width:100px;">电话</th>
					<th style="width:100px;">下单时间</th>
					<th style="width:150px;">订单号</th>
					<th style="width:100px;">用餐时间</th>
					<th style="width:100px;">用餐地点</th>
					<th style="width:100px;">总价</th>
					<th style="width:100px;">订单状态</th>
					<th style="width:100px;">支付状态</th>
					<th style="width:320px;">操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $orders $item}
			<tr>
				<td class="with-checkbox">
					<input type="checkbox" name="check_order" value="{$item['id']}">
				</td>
				<td>{$item['contact_name']}</td>
				<td>{$item['mobile']}</td>
				<td>{php echo date('Y-m-d H:i', $item['time'])}</td>
				<td>{$item['ordersn']}</td>
				<td>{php echo date('Y-m-d H:i', $item['eattime'])}</td>
				<td>{$item['place']}</td>
				<td>{$item['sumprice']}</td>
				<td>{if $item['status'] == -1}已取消{else if $item['status'] == 0}未确认{else if $item['status'] == 1}已确认{else if $item['status'] == 2}已完成{/if}</td>
				<td>{if $item['paystatus'] == 1}已支付{else}未支付{/if}</td>
				<td>
					<div>
						<a class="wn-table__link__item" href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_editorder', 'id' => $item['id'], 'storeid' => $storeid))}" title="编辑">编辑</a>
						<a class="wn-table__link__item" href="javascript:;" onclick="drop_confirm('您确定要删除吗?', '{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_deleteorder', 'id' => $item['id'], 'storeid' => $storeid))}');" title="删除">删除</a>
					</div>
				</td>
			</tr>
			{/loop}
			<tr>
				<td colspan="11">
					<input type="button" class="btn btn-primary" name="foods_deleteorderall" value="删除选择的" />
					<div class="pull-right">
						{$pager}
					</div>
				</td>
			</tr>
			</tbody>
			<input name="token" type="hidden" value="{$_W['token']}" />
		</table>
		{/if}
		{if $op == 'foods_editorder'}
		<div class="wn-main__search__action">
			<a href="{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_order', 'storeid' => $storeid));}" class="btn btn-primary we7-padding-horizontal">返回餐品订单列表</a>
		</div>
		<div class="wn-main__content">
			<form action="" class="form-horizontal form" method="post" enctype="multipart/form-data">
				<input type="hidden" name="orderid" value="{$order['id']}">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">联系人</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{$order['contact_name']}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机号</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{$order['mobile']}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">下单时间</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{php echo date('Y-m-d H:i', $order['time'])}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单号</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{$order['ordersn']}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用餐时间</label>
					<div class="col-xs-12 col-sm-9 col-md-9" style="color:red">
						{php echo date('Y-m-d H:i', $order['eattime'])}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">用餐地点</label>
					<div class="col-xs-12 col-sm-9 col-md-9" style="color:red">
						{$order['place']}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">总价</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{$order['sumprice']}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单状态</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{if $order['status'] == -1}已取消{else if $order['status'] == 0}未确认{else if $order['status'] == 1}已确认{else if $order['status'] == 2}已完成{/if}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">支付状态</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{if $order['paystatus'] == 1}已支付{else}未支付(或线下支付){/if}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单详情</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						<table class="table table-hover wn-table table-bordered" >
							<thead class="navbar-inner">
								<tr>
									<th style="width:100px;">名称</th>
									<th style="width:100px;">单价</th>
									<th style="width:100px;">数量</th>
								</tr>
							</thead>
							<tbody>
							{loop $order['foods'] $val}
							<tr>
								<td>{$val['title']}</td>
								<td>{$val['price']}</td>
								<td>{$val['num']}</td>
							</tr>
							{/loop}
						</table>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客户留言</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						<textarea readonly style="height:50px;" class="form-control richtext-clone" name="remark" cols="70" id="">{$order['remark']}</textarea>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">操作</label>
					<div class="col-xs-12 col-sm-9 col-md-9">
						{if $order['status'] == 0}
						<button type="button" name="status" class="btn but{if $order['status'] == -1} btn-primary{/if} btn-default"  value=-1>订单取消</button>
						{/if}
						{if $order['status'] != -1}
						{if $order['status'] != 2 &&  $order['status'] != 1}
						<button type="button" name="status" class="btn but{if $order['status'] == 1} btn-primary{/if} btn-default"  value=1>订单确认</button>
						{/if}
						<button type="button" name="status" class="btn but{if $order['status'] == 2} btn-primary{/if} btn-default"  value=2>订单完成</button>
						{/if}
					</div>
				</div>
			</form>
		</div>
		{/if}
	</div>
</div>

<script type="text/javascript">
	$(function () {
		$("#add_food_place").click(function() {
			var index = $('.place-input').length;
			var html =
				'<div class="col-sm-11" style="margin: 5px 0px;">' +
					'<div class="input-group">' +
						'<input type="text" class="form-control place-input" maxlength="6" name="place[' + index + ']" value="">' +
						'<span class="input-group-btn">' +
							'<button class="btn btn-default place-delete" type="button">删除</button>' +
						'</span>' +
					'</div>' +
				'</div>';

			$(this).parent().before(html);
		});
		$(document).on('click', '.place-delete', function() {
			$(this).parent().parent().parent().remove();
		});
		$("#add_food_time").click(function() {
			var index = $('.time-input').length;
			var html =
				'<div class="col-sm-11" style="margin: 5px 0px;">' +
					'<div class="input-group">' +
						'<input type="text" class="form-control time-input" maxlength="6" name="time[' + index + ']" value="">' +
						'<span class="input-group-btn">' +
							'<button class="btn btn-default time-delete" type="button">删除</button>' +
						'</span>' +
					'</div>' +
				'</div>';

			$(this).parent().before(html);
		});
		$(document).on('click', '.time-delete', function() {
			$(this).parent().parent().parent().remove();
		});
		
		
		$('.check_all_foods').click(function() {
			var checked = $(this).get(0).checked;
			$('input[type=checkbox]').prop("checked",checked);
		});
		$('input[name=foods_deleteall]').click(function() {
			var check = $("input[name='check_foods']:checked");
			if (check.length < 1) {
				util.message('请选择要删除的记录!');
				return;
			}
			if (confirm("确认要删除选择的记录?")) {
				var id = new Array();
				check.each(function(i) {
					id[i] = $(this).val();
				});
				$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_deleteall', 'storeid' => $storeid))}", {idArr : id}, function(data) {
					if (data.message.errno ==0) {
						util.message(data.message.message, 'refresh', 'success');
						return;
					} else {
						util.message(data.message.message);
						return;
					}
				},'json');
			}
		});
		
		$('.foods_edit_all').click(function() {
			var name = $(this).attr('name');
			var check = $("input[name='check_foods']:checked");
			if (check.length < 1) {
				util.message('请选择要操作的记录!');
			}
			var id = new Array();
			check.each(function(i) {
				id[i] = $(this).val();
			});
			$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice',array('op' => 'foods_showall', 'storeid' => $storeid))}", {idArr:id, show_name:name},function(data) {
				if (data.message.errno ==0) {
					util.message(data.message.message, 'refresh', 'success');
				} else {
					util.message(data.message.message);
				}
			},'json');
		});
		
		$('.check_all_order').click(function() {
			var checked = $(this).get(0).checked;
			$('input[type=checkbox]').prop("checked",checked);
		});
		$('input[name=foods_deleteorderall]').click(function() {
			var check = $("input[name='check_order']:checked");
			if (check.length < 1) {
				util.message('请选择要删除的记录!');
				return;
			}
			if (confirm("确认要删除选择的记录?")) {
				var id = new Array();
				check.each(function(i) {
					id[i] = $(this).val();
				});
				$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_deleteorderall', 'storeid' => $storeid))}", {idArr : id}, function(data) {
					if (data.message.errno ==0) {
						util.message(data.message.message, 'refresh', 'success');
						return;
					} else {
						util.message(data.message.message);
						return;
					}
				},'json');
			}
		});
		
		$('button[name=status]').click(function() {
			var status = $(this).val();
			var id = $('input[name=orderid]').val();
			if (status) {
				$.post("{php echo $this->createWebUrl('shop_plugin_hotelservice', array('op' => 'foods_editorder', 'storeid' => $storeid))}", {id : id, status : status}, function(data) {
					if (data.message.errno ==0) {
						util.message(data.message.message, 'refresh', 'success');
						return;
					} else {
						util.message(data.message.message);
						return;
					}
				},'json');
			}
		});
	});
	
	function drop_confirm(msg, url) {
		if (confirm(msg)) {
			window.location = url;
		}
	}
</script>
{template 'common/footer-storex'}